package com.example.practice.sqlite;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import androidx.annotation.Nullable;

public class SQLiteHelper extends SQLiteOpenHelper {
    private static final int DB_VERSION = 1;
    public static String DB_NAME = "db_yl";
    public static final String U_USERINFO = "userinfo";

    public SQLiteHelper(Context context){
        super(context,DB_NAME,null,DB_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL("create table if not exists " +U_USERINFO+ "(id INTEGER primary key autoincrement, userName VARCHAR, nickName VARCHAR, sex VARCHAR,signature VARCHAR)");


        //        创建播放视频记录表
        db.execSQL("CREATE TABLE IF NOT EXISTS videoplaylist ("
                +"_id INTEGER PRIMARY KEY AUTOINCREMENT,"
                +"userName VARCHAR,"
                +"chapterId INT,"
                +"videoId INT,"
                +"videoPath VARCHAR,"
                +"title VARCHAR,"
                +"secondTitle VARCHAR"
                +")");
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL("drop table if exists " + U_USERINFO);
        onCreate(db);
    }
}
